; Script generated with the Venis Install Wizard

; Define your application name
!define APPNAME "Unofficial Chinese Clone Support"
!define APPNAMEANDVERSION "Unofficial Chinese Clone Support 0.21"

; Main Install settings
Name "${APPNAMEANDVERSION}"
InstallDir "$PROGRAMFILES\Unofficial Chinese Clone Support"
InstallDirRegKey HKLM "Software\${APPNAME}" ""
OutFile "UCCS Setup.exe"

; Modern interface settings
!include "MUI.nsh"

!define MULTIUSER_EXECUTIONLEVEL Highest
!include MultiUser.nsh

!define MUI_ABORTWARNING
!define MUI_FINISHPAGE_RUN "$INSTDIR\UCCS.exe"

Function .onInit

  !insertmacro MULTIUSER_INIT

FunctionEnd



Function un.onInit

  !insertmacro MULTIUSER_UNINIT

FunctionEnd

!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE "License.txt"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH

!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES

; Set languages (first is default language)
!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_RESERVEFILE_LANGDLL

Section "Unofficial Chinese Clone Support" Section1

	; Set Section properties
	SectionIn RO
	SetOverwrite on

	; Set Section Files and Shortcuts
	SetOutPath "$INSTDIR\"
	File "AutohotkeyRemoteControl.dll"
	File "License.txt"
	File "Readme.txt"
	File "UCCS.exe"
	File "UCCS.ico"
SectionEnd

Section -FinishSection

	WriteRegStr HKLM "Software\${APPNAME}" "" "$INSTDIR"
	WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "DisplayName" "${APPNAME}"
	WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}" "UninstallString" "$INSTDIR\uninstall.exe"
	WriteUninstaller "$INSTDIR\uninstall.exe"

SectionEnd

Section "Create start menu shortcuts" Section2
	SetOverwrite on
	CreateDirectory "$SMPROGRAMS\Unofficial Chinese Clone Support"
	CreateShortCut "$SMPROGRAMS\Unofficial Chinese Clone Support\Unofficial Chinese Clone Support.lnk" "$INSTDIR\UCCS.exe"
	CreateShortCut "$SMPROGRAMS\Unofficial Chinese Clone Support\Uninstall.lnk" "$INSTDIR\uninstall.exe"
SectionEnd

Section "Create desktop shortcut" Section3
	SetOverwrite on
	CreateShortCut "$DESKTOP\Unofficial Chinese Clone Support.lnk" "$INSTDIR\UCCS.exe"
SectionEnd

Section "Run at windows startup" Section4
	SetOverwrite on
	WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Run" "Unofficial Chinese Clone Support" "$INSTDIR\UCCS.exe"
SectionEnd

; Modern install component descriptions
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
	!insertmacro MUI_DESCRIPTION_TEXT ${Section1} ""
	!insertmacro MUI_DESCRIPTION_TEXT ${Section2} ""
	!insertmacro MUI_DESCRIPTION_TEXT ${Section3} ""
	!insertmacro MUI_DESCRIPTION_TEXT ${Section4} ""
!insertmacro MUI_FUNCTION_DESCRIPTION_END

;Uninstall section
Section Uninstall

	;Remove from registry...
	DeleteRegValue HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Run" "Unofficial Chinese Clone Support"
	DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${APPNAME}"
	DeleteRegKey HKLM "SOFTWARE\${APPNAME}"

	; Delete self
	Delete "$INSTDIR\uninstall.exe"

	; Delete Shortcuts
	Delete "$DESKTOP\Unofficial Chinese Clone Support.lnk"
	;SetShellVarContext current
	Delete "$SMPROGRAMS\Unofficial Chinese Clone Support\Unofficial Chinese Clone Support.lnk"
	Delete "$SMPROGRAMS\Unofficial Chinese Clone Support\Uninstall.lnk"

	; Clean up Unofficial Chinese Clone Support
	Delete "$INSTDIR\AutohotkeyRemoteControl.dll"
	Delete "$INSTDIR\License.txt"
	Delete "$INSTDIR\Readme.txt"
	Delete "$INSTDIR\UCCS.exe"
	Delete "$INSTDIR\UCCS.ico"

	; Remove remaining directories
	RMDir "$SMPROGRAMS\Unofficial Chinese Clone Support"
	RMDir "$INSTDIR\"

SectionEnd

; eof